package com.example.webflux_module.controller;

import cn.hutool.core.thread.ThreadUtil;
import com.example.webflux_module.entity.Result;
import com.example.webflux_module.entity.Results;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;


@Slf4j
@RestController
@RequestMapping("/mono")
public class MonoController {

    @RequestMapping("/echo")
    public Mono<Result> echo(String name) {

        log.info("echo echo echo: {}", name);
        return Mono.just(Results.ok()).map(e -> {
            ThreadUtil.sleep(5000);
            log.info("11111111");
            return Results.ok("0000");
        });
    }
}
